<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:p="http://primefaces.org/ui"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>#{rotulos.labelRegister}</title>
        <script type="text/javascript">
         
        function IsEmail(email){
            var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
            var check=/@[\w\-]+\./;
            var checkend=/\.[a-zA-Z]{2,3}$/;
            if(((email.search(exclude) != -1)||(email.search(check)) == -1)||(email.search(checkend) == -1)){
               document.getElementById('user:e').style.color="red";
               document.getElementById('user:e').innerText = "Email*";
                return false;
            }
            else {
                document.getElementById('user:e').style.color="";
                return true;
                }
        }
        
        </script>
    </h:head>
    <h:body>
        <center>
            <p:panel header="#{rotulos.labelRegister}" style="text-align:left;width:700px;">
            <div>
                    <h:form id="user" acceptcharset="ISO-8859-1">
                        <h:panelGrid cellpadding="5" columns="3">
                            <p:growl id="messages" showDetail="true"/>
                            <h:outputLabel value="#{rotulos.labelName}" />
                            <h:inputText id="name" value="#{userController.user.name}"
                                         required="true" requiredMessage="#{rotulos.labelMessageNameEmpty}"
                                         styleClass="comboStyle"
                                         >
                            </h:inputText><br/>
                            <h:outputLabel value="#{rotulos.labelInstitution}" />
                            <h:inputText id="institution" value="#{userController.user.institution}"
                                         required="true" requiredMessage="#{rotulos.labelMessageInstitution}"
                                         styleClass="comboStyle"
                                         >
                            </h:inputText><br/>
                            <h:outputLabel value="#{rotulos.labelPurpose}" />
                            <h:inputText id="purpose" value="#{userController.user.purpose}"
                                         required="true" requiredMessage="#{rotulos.labelMessagePurpose}"
                                         styleClass="comboStyle"
                                         >
                            </h:inputText><br/>
                            <h:outputLabel value="#{rotulos.labelEmail}" id="e" />
                            <h:inputText id="email" value="#{userController.user.email}"
                                         required="true" requiredMessage="#{rotulos.labelMessageEmailEmpty}"
                                         styleClass="comboStyle"
                                         onblur="return IsEmail(this.value);"
                                         >
                            </h:inputText>
                            <br/>
                            <h:outputLabel value="#{rotulos.labelPassword}" />
                            <h:inputSecret id="password" value="#{userController.user.password}"
                                           required="true" requiredMessage="#{rotulos.labelMessagePasswordEmpty}"
                                         styleClass="comboStyle"
                                         maxlength="8"
                                         >
                            </h:inputSecret><br/>
                            <p:commandButton ajax="false" value="#{rotulos.labelSubmit}" actionListener="#{userController.saveUser}" onclick="return valid()"/>
                            <p:commandButton type="reset" value="#{rotulos.clear}"/>
                            <center><h:commandButton value="#{rotulos.labelBack}" action="#{userController.prepLogin}" immediate="true"/>
                            </center>
                        </h:panelGrid>
                    </h:form>
            </div>
        </p:panel>
        </center>
    </h:body>
</html>
